/*
 * CGI Functions Header
 * Author: Qoder
 * Description: Header file for CGI functionality
 */

#ifndef CGI_FUNCTIONS_H
#define CGI_FUNCTIONS_H

#include "server_functions.h"

// CGI response structure
typedef struct {
    char *content_type;
    char *body;
    int status_code;
} cgi_response_t;

// Function prototypes for CGI handlers
void process_cgi_request(int client_fd, http_request_t *request);

// Specific CGI endpoint handlers
void cgi_get_time(int client_fd, http_request_t *request);
void cgi_get_status(int client_fd, http_request_t *request);
void cgi_get_version(int client_fd, http_request_t *request);
void cgi_echo_post(int client_fd, http_request_t *request);

// Utility functions for CGI
char *get_system_time_json(void);
char *get_system_status_json(void);
char *get_version_info_json(void);
char *parse_query_parameter(const char *query_string, const char *param_name);

// Memory management
void free_cgi_response(cgi_response_t *response);

#endif // CGI_FUNCTIONS_H